﻿using huaxin_Model;
using huaxin_Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Web.Controllers;
using Web.Models;

namespace huaxin_luckdraw.Controllers
{
    public class HomeController : BaseController
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        //[HttpPost]
        //public JsonResult RemoteOrder(RemoteOrderModel model)
        //{
        //    PayStateModel jsonRes = null;

        //    HttpRequest request = System.Web.HttpContext.Current.Request;
        //    //string ip = XYD.Common.Request.GetIP();

        //    try
        //    {
        //        Product product = new Product();
        //        if (product == null)
        //        {
        //            return Json(jsonRes = new PayStateModel() { state = false, error_msg = "商品参数错误" }, JsonRequestBehavior.AllowGet);
        //        }

        //        PayOrder payOrder = new PayOrder();

        //        payOrder.OpenId = this.OpenId;
        //        payOrder.SourceOpenId = this.OpenId;
        //        payOrder.AccountId = 20000;
        //        payOrder.ChannelId = model.cid;
        //        payOrder.PUserCode = model.ucode;
        //        payOrder.ProductId = product.id.ToString();
        //        payOrder.ProductName = product.name;
        //        payOrder.AddDate = DateTime.Now;
        //        payOrder.IsPay = 0;
        //        payOrder.PayAmount = product.price;
        //        payOrder.Ip = "127.0.0.1";
        //        payOrder.Tel = model.phone;
        //        payOrder.OrderId = GetOrderNumber();
        //        payOrder.Remark = model.uname;
        //        if (dal.Insert<PayOrder>(payOrder))
        //        {
        //            return Json(jsonRes = new PayStateModel() { state = true, error_msg = "", orderId = payOrder.OrderId }, JsonRequestBehavior.AllowGet);
        //        }
        //        else
        //        {
        //            return Json(jsonRes = new PayStateModel() { state = false, error_msg = "下单失败,请联系客服" }, JsonRequestBehavior.AllowGet);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Debuglog("订单异常：" + ex.Message);
        //        jsonRes = new PayStateModel()
        //        {
        //            state = false,
        //            error_msg = "订单提交失败"
        //        };
        //        return Json(jsonRes, JsonRequestBehavior.AllowGet);
        //    }
        //}

        //public static string GetOrderNumber()
        //{
        //    string Number = DateTime.Now.ToString("yyMMddHHmmss");//yyyyMMddHHmmssms
        //    return Number + Next(1000, 1).ToString();
        //}
    }
}